package com.marvels.common.dto;

import java.util.Date;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.marvels.common.exception.MarvelsBusinessException;
import com.marvels.common.utils.CacheUtils;

/**
 * base DTO
 * 
 * @author wangliang
 *
 */
public class BaseDTO extends JsonDTO {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	// 创建时间
	private Date createdDate;
	// 更新时间
	private Date updatedDate;
	// 创建人
	private String createdBy;
	// 更新人
	private String updatedBy;
	// 删除标识：0未删除 1已删除
	private Integer deleteFlag;

	public Date getCreatedDate() {
		return createdDate;
	}

	public void setCreatedDate(Date createdDate) {
		this.createdDate = createdDate;
	}

	public Date getUpdatedDate() {
		return updatedDate;
	}

	public void setUpdatedDate(Date updatedDate) {
		this.updatedDate = updatedDate;
	}

	public String getCreatedBy() {
		return createdBy;
	}

	public void setCreatedBy(String createdBy) {
		this.createdBy = createdBy;
	}

	public String getUpdatedBy() {
		return updatedBy;
	}

	public void setUpdatedBy(String updatedBy) {
		this.updatedBy = updatedBy;
	}

	public Integer getDeleteFlag() {
		return deleteFlag;
	}

	public void setDeleteFlag(Integer deleteFlag) {
		this.deleteFlag = deleteFlag;
	}

	@JSONField(serialize = false)
	@JsonIgnore
	public String obtainLoginUserName() throws MarvelsBusinessException {
		UserDTO user = CacheUtils.getCacheUser();
		if (user == null) {
			throw new MarvelsBusinessException("cache中的user对象为空");
		}
		return user.getUserCode();
	}
}
